<?php
// 获取单个商品信息（下架）
// header("content-type:text/html;charset=utf-8");
include_once("conn.php");

$gid = $_GET["gid"];

$sql = "SELECT * FROM tb_goods_info WHERE g_id = '" . $gid . "'";
$res = mysqli_query($conn, $sql);
if ($res) {
    if (mysqli_num_rows($res) > 0) {
        $row = mysqli_fetch_assoc($res);
    }else{
        echo "该商品不存在，请检查商品ID";
        die();
    }
} else {
    echo "查询失败";
    die();
}

if ($row['g_is_sell'] != 1) {
    echo "该商品已下架";
    die();
}

echo "
<form action='php/outline-goods.php' class='outline-form' method='post'>
    <div class='goods_img'>
        <img src='../goods_imgs/" . $row['g_img'] . "'>
    </div>
    <div class='mb-3 row'>
        <label for='gid' class='col-sm-3 col-form-label'>商品ID</label>
        <div class='col-sm-9'>
            <input type='text' readonly class='form-control-plaintext' id='gid' name='gid' value='" . $row['g_id'] . "'>
        </div>
    </div>
    <div class='mb-3 row'>
        <label for='gname' class='col-sm-3 col-form-label'>商品名称</label>
        <div class='col-sm-9'>
            <input type='text' readonly class='form-control-plaintext' id='gname' value='" . $row['g_name'] . "'>
        </div>
    </div>
    <div class='btndiv'>
        <button type='submit' class='btn btn-outline-danger' onclick='return outlineGoods();'>下架该商品</button>
    </div>
</form>

";
